#include <18F2520.h>
#device adc=10
#fuses HS,NOMCLR,NOWDT,NOPUT,NOPROTECT
#use delay (clock=20000000)

#define SW PIN_B7
#define LED PIN_B6

#include <numeros.h>

void main ()
{

int a=2,r=0;
int16 q;
float p;



//Usar para el caso real 
int Nums[11]={0b00000001,0b11001111,0b10010010,0b10000110,0b11001100,0b10100100,0b10100000,0b10001111,0b00000000,0b00001100};

//Usar para simulacion
//int Nums[11]={0b00000011,0b10011111,0b00100101,0b00001101,0b10011001,0b01001001,0b01000001,0b00011111,0b00000001,0b00011001};
/*
setup_adc_ports(AN0);      //Canal 0 analogico
setup_adc(ADC_CLOck_div_2);
set_adc_channel(0);


delay_us(20);
q=read_adc();
p=5.0*q/1024.0;
a=p;
r=p/10;
*/
 numero(Nums[a],PIN_B0,PIN_B1);
      numero(Nums[r],PIN_B2,PIN_B3);
      delay_ms(2000);
output_high(LED);
while(1)
{
if(input(SW)==1)
{r++;
      numero(Nums[a],PIN_B0,PIN_B1);
      numero(Nums[r],PIN_B2,PIN_B3);
   }
   delay_ms(700);
}
}

